const app = getApp()

Page({
  data: {
    userInfo: null,
    isLogin: false,
    mouseName: '小灰灰',
    mouseLevel: 1,
    mouseExp: 0,
    nextLevelExp: 100,
    coins: 0,
    crops: []
  },

  onLoad() {
    
  },

  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1
      })
    }
  },

  loadFarmData() {
    // TODO: 从服务器加载农场数据
    this.setData({
      coins: 100,
      crops: [
        { id: 1, name: '胡萝卜', status: 'growing', progress: 50 },
        { id: 2, name: '南瓜', status: 'ready', progress: 100 },
        { id: 3, name: '玉米', status: 'empty', progress: 0 }
      ]
    })
  },

  plantCrop(e) {
    const { cropId } = e.currentTarget.dataset
    console.log('种植作物:', cropId)
  },

  harvestCrop(e) {
    const { cropId } = e.currentTarget.dataset
    console.log('收获作物:', cropId)
  },

  feedMouse() {
    console.log('喂养鼠鼠')
  }
}) 